package com.example.tests;

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import java.util.Random;
import org.testng.annotations.Test;
import com.example.utils.SortedListOf;

public class GroupModificationTests extends TestBase {
	
	@Test(dataProvider ="randomValidGroupGenerator")

	public void modifaySameGroup (GroupDate group) {
		
		// save old state
		SortedListOf<GroupDate> oldList = app.getGroupHelper().getGroups();
		
		Random rnd = new Random();
		int index = rnd.nextInt(oldList.size()-1);
							
		// actions
		app.getGroupHelper().modifyGroup(index,group);
				    
		// save new state
		SortedListOf<GroupDate> newList = app.getGroupHelper().getGroups();
		    
		// compare states
		assertThat(newList, equalTo(oldList.without(index).withAdded(group))); 
				
	}

}
